package com.ruoyi.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.domain.Elderlyinfo;
import com.ruoyi.service.IElderlyinfoService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * ElderlyinfoController
 * 
 * @author 王皎宇
 * @date 2025-01-10
 */
@RestController
@RequestMapping("/elderlyinfo")
public class ElderlyinfoController extends BaseController
{
    @Autowired
    private IElderlyinfoService elderlyinfoService;

    /**
     * 查询Elderlyinfo列表
     */
    @RequiresPermissions("gov:elderlyinfo:list")
    @GetMapping("/list")
    public TableDataInfo list(Elderlyinfo elderlyinfo)
    {
        startPage();
        List<Elderlyinfo> list = elderlyinfoService.selectElderlyinfoList(elderlyinfo);
        return getDataTable(list);
    }

    /**
     * 导出Elderlyinfo列表
     */
    @RequiresPermissions("gov:elderlyinfo:export")
    @Log(title = "Elderlyinfo", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Elderlyinfo elderlyinfo)
    {
        List<Elderlyinfo> list = elderlyinfoService.selectElderlyinfoList(elderlyinfo);
        ExcelUtil<Elderlyinfo> util = new ExcelUtil<Elderlyinfo>(Elderlyinfo.class);
        util.exportExcel(response, list, "Elderlyinfo数据");
    }

    /**
     * 获取Elderlyinfo详细信息
     */
    @RequiresPermissions("gov:elderlyinfo:query")
    @GetMapping(value = "/{elderlyId}")
    public AjaxResult getInfo(@PathVariable("elderlyId") Long elderlyId)
    {
        return success(elderlyinfoService.selectElderlyinfoByElderlyId(elderlyId));
    }

    /**
     * 新增Elderlyinfo
     */
    @RequiresPermissions("gov:elderlyinfo:add")
    @Log(title = "Elderlyinfo", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Elderlyinfo elderlyinfo)
    {
        return toAjax(elderlyinfoService.insertElderlyinfo(elderlyinfo));
    }

    /**
     * 修改Elderlyinfo
     */
    @RequiresPermissions("gov:elderlyinfo:edit")
    @Log(title = "Elderlyinfo", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Elderlyinfo elderlyinfo)
    {
        return toAjax(elderlyinfoService.updateElderlyinfo(elderlyinfo));
    }

    /**
     * 删除Elderlyinfo
     */
    @RequiresPermissions("gov:elderlyinfo:remove")
    @Log(title = "Elderlyinfo", businessType = BusinessType.DELETE)
	@DeleteMapping("/{elderlyIds}")
    public AjaxResult remove(@PathVariable Long[] elderlyIds)
    {
        return toAjax(elderlyinfoService.deleteElderlyinfoByElderlyIds(elderlyIds));
    }
}
